
        -- Author:		<ngvanty03@gmail.com>
        -- Create date: <Create Date,,>
        -- Description:	<Description,,>
        -- =============================================
        CREATE PROCEDURE  spGetAllSubCategory_Trans	       
        AS
        BEGIN
	       Select [subCategoryId],[subCategoryName],[createdBy],[createdDate],[lastUpdatedBy],[lastUpdatedDate],[languageId] from SubCategory_Trans
        END
        GO
           
        -- Author:		<ngvanty03@gmail.com>
        -- Create date: <Create Date,,>
        -- Description:	<Description,,>
        -- =============================================
        CREATE PROCEDURE spGetSubCategory_Trans  
        (
        @SubCategoryId int ,
@LanguageId varchar (10)
        )      
        AS
        BEGIN	       
	        SELECT [subCategoryId],[subCategoryName],[createdBy],[createdDate],[lastUpdatedBy],[lastUpdatedDate],[languageId] from SubCategory_Trans where [subCategoryId]=@SubCategoryId and [languageId]=@LanguageId
        END
        GO
        
            -- Author:ngvanty03@gmail.com		
            -- Create date: <Create Date,,>
            -- Description:	<Description,,>
            -- =============================================
            CREATE PROCEDURE spInsertSubCategory_Trans
            (
            
@SubCategoryId int,
@SubCategoryName nvarchar(50),
@CreatedBy nvarchar(256),
@CreatedDate datetime,
@LastUpdatedBy nvarchar(256),
@LastUpdatedDate datetime,
@LanguageId varchar(10)
            )
            AS
            begin
                Insert into SubCategory_Trans([subCategoryId],[subCategoryName],[createdBy],[createdDate],[lastUpdatedBy],[lastUpdatedDate],[languageId]) values (@SubCategoryId,@SubCategoryName,@CreatedBy,@CreatedDate,@LastUpdatedBy,@LastUpdatedDate,@LanguageId)
                if(@@ERROR<>0)--Insert Error
                    return 0;
                return 1;
            end
            GO
            -- Author:ngvanty03@gmail.com		
            -- Create date: <Create Date,,>
            -- Description:	<Description,,>
            -- =============================================
            CREATE PROCEDURE spUpdateSubCategory_Trans
            (
            
@SubCategoryId int,
@SubCategoryName nvarchar(50),
@CreatedBy nvarchar(256),
@CreatedDate datetime,
@LastUpdatedBy nvarchar(256),
@LastUpdatedDate datetime,
@LanguageId varchar(10)
            )
            AS
            begin
                Update SubCategory_Trans set [subCategoryName]=@SubCategoryName,[createdBy]=@CreatedBy,[createdDate]=@CreatedDate,[lastUpdatedBy]=@LastUpdatedBy,[lastUpdatedDate]=@LastUpdatedDate where [subCategoryId]=@SubCategoryId and [languageId]=@LanguageId
                if(@@ERROR<>0)--Update Error
                    return 0;
                return 1;
            end
            GO
            -- Author:ngvanty03@gmail.com		
            -- Create date: <Create Date,,>
            -- Description:	<Description,,>
            -- =============================================
            CREATE PROCEDURE spInsertUpdateSubCategory_Trans
            (
            
@SubCategoryId int,
@SubCategoryName nvarchar(50),
@CreatedBy nvarchar(256),
@CreatedDate datetime,
@LastUpdatedBy nvarchar(256),
@LastUpdatedDate datetime,
@LanguageId varchar(10)
            )
            AS
            begin
                if exists(Select subCategoryId from SubCategory_Trans where [subCategoryId]=@SubCategoryId and [languageId]=@LanguageId)
                begin
                    Update SubCategory_Trans set [subCategoryName]=@SubCategoryName,[createdBy]=@CreatedBy,[createdDate]=@CreatedDate,[lastUpdatedBy]=@LastUpdatedBy,[lastUpdatedDate]=@LastUpdatedDate where [subCategoryId]=@SubCategoryId and [languageId]=@LanguageId
                    if(@@ERROR<>0)--Update Error
                        return 0;
                    return 1;
                end
                else
                    begin
                        Insert into SubCategory_Trans([subCategoryId],[subCategoryName],[createdBy],[createdDate],[lastUpdatedBy],[lastUpdatedDate],[languageId]) values (@SubCategoryId,@SubCategoryName,@CreatedBy,@CreatedDate,@LastUpdatedBy,@LastUpdatedDate,@LanguageId)
                        if(@@ERROR<>0)--Insert Error
                            return 0;
                        return 1;   
                    end
            end
            GO
        -- Author:		<ngvanty03@gmail.com>
        -- Create date: <Create Date,,>
        -- Description:	<Description,,>
        -- =============================================
        CREATE PROCEDURE  spGetAllLanguageofItemSubCategory_Trans	
        (
            @SubCategoryId int 
        )       
        AS
        BEGIN
	       Select [subCategoryId],[subCategoryName],[createdBy],[createdDate],[lastUpdatedBy],[lastUpdatedDate],[languageId] from SubCategory_Trans
           where [subCategoryId]=@SubCategoryId
        END
        GO
           
        -- Author:		<ngvanty03@gmail.com>
        -- Create date: <Create Date,,>
        -- Description:	<Description,,>
        -- =============================================
        
        CREATE PROCEDURE spDeleteSubCategory_Trans  
        (
        @SubCategoryId int ,
@LanguageId varchar (10)
        )      
        AS
        BEGIN tran
            DELETE from SubCategory_Trans_Trans  where [subCategoryId]=@SubCategoryId and [languageId]=@LanguageId
            if(@@ERROR<>0)--error
                goto lblError;
	        DELETE from SubCategory_Trans  where [subCategoryId]=@SubCategoryId and [languageId]=@LanguageId
           if(@@ERROR<>0)--error
                goto lblError;
           goto lblOK;
        lblOK:
			commit tran;
			return 1;
		lblError:
			rollback tran;
			return 0	           
        GO
        